﻿using LdtJudge.DataEngine.CallInterface.CommHelp;
using LdtJudge.DataEngine.Model.DataModel.DataParseStorage;
using System;
using System.Collections.Generic;
using System.Text;

namespace LdtJudge.DataEngine.Data.DataParseStorage
{
    /// <summary>
	/// 案件信息表
	/// </summary>
    public class DAL_An_anjianxinxi
    {
        private IFreeSql FreeSql = FreeSQLHelp.GetFreeSQL("Ldt_DataParseStorage");
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="anjid">条件</param>
        /// <returns></returns>
        public List<An_anjianxinxi> GetList(string anjianid)
        {
            return FreeSql.Select<An_anjianxinxi>().Where(a => a.Anjianid == anjianid)?.ToList();
        }

        /// <summary>
        /// 添加案件中的实体数据
        /// </summary>
        /// <param name="model">案件数据存储模型</param>
        /// <returns></returns>
        public int Insert(An_anjianxinxi model)
        {
            return FreeSql.Insert<An_anjianxinxi>(model).ExecuteAffrows();
        }

        /// <summary>
        /// 更新案件中的实体数据
        /// </summary>
        /// <param name="model">案件数据存储模型</param>
        /// <returns></returns>
        public int Update(An_anjianxinxi model)
        {
            return FreeSql.Update<An_anjianxinxi>(model).SetSourceIgnore(model, col => col == null).ExecuteAffrows();
        }

        /// <summary>
        /// 添加案由实体数据
        /// </summary>
        public int IntsertAnyouXini(An_anyouxinxi model) 
        {
            return FreeSql.Insert<An_anyouxinxi>(model).ExecuteAffrows();
        }

        /// <summary>
        /// 删除案由实体数据
        /// </summary>
        public int DeletetAnyouXini(An_anyouxinxi model)
        {
            return FreeSql.Delete<An_anyouxinxi>(model).ExecuteAffrows();
        }

        /// <summary>
        /// 通过案件Id查询案由实体集合
        /// </summary>
        public List<An_anyouxinxi> GetanyouxinxiList(string anjianid) 
        {
            return FreeSql.Select<An_anyouxinxi>().Where(a => a.Anjianid == anjianid).CommandTimeout(600)?.ToList();
        }

        /// <summary>
        /// 通过案件ID查询案由实体信息
        /// </summary>
        public An_anyouxinxi GetAnYouxinxiByAnjianid(string anjianid)
        {
            return FreeSql.Select<An_anyouxinxi>().Where(a => a.Anjianid == anjianid).CommandTimeout(600)?.ToOne();
        }

        /// <summary>
        /// 通过案件ID查询案件信息
        /// </summary>
        /// <param name="anjianid">案件ID</param>
        /// <returns></returns>
        public An_anjianxinxi GetAnjianxinxiById(string anjianid)
        {
            return FreeSql.Select<An_anjianxinxi>().Where(a => a.Anjianid == anjianid).CommandTimeout(600)?.ToOne();
        }
    }
}
